﻿using Dict.DataModel;
using System.Collections;
using UnityEngine;
namespace Story
{
    class StepPlayParticle : StepBase
    {
        protected override void OnStart()
        {
            var particle = Dict.Blo.DictParticleBlo.GetParticle(actionParam1);
            string path = "particles/" + particle.ResourcePath;
            float time = (float)particle.Duration;

            Vector3 pos = GetPosition(actionParam2);
            float angle = float.Parse(actionParam3);

            AssetLoadHelper.Instance.LoadAssetAsync(path, CommonMethod.GetAssetNameFromAssetBundleName(path), typeof(GameObject),
                (asset) =>
                {
                    GameObject obj = asset as GameObject;
                    if (obj != null)
                    {
                        obj.SetActive(true);
                        obj.transform.position = new Vector3(pos.x, pos.y, pos.z);
                        obj.transform.localScale = Vector3.one;
                        obj.transform.localEulerAngles = new Vector3(0, angle, 0);

                        GameObject.Destroy(obj, time);
                    }
                    End();
                });
        }

    }
}